package com.lijianpo.util.extension.enums;

import com.google.common.collect.HashBasedTable;
import com.lijianpo.util.extension.api.IErrorCode;

import java.util.Map;

/**
 * ---------------------------
 * 错误码 (ErrorCodeEnum)
 * 错误产生来源分为 A1/B2/C3:
 * A1 表示错误来源于用户，比如参数错误
 * B2 表示错误来源于当前系统，往往是业务逻辑出错，或程序健壮性差等问题
 * C3 表示错误来源于第三方服务，比如 CDN 服务出错，消息投递超时等问题
 * 四位数字编号从 0001 到 9999，大类之间的步长间距预留 100
 * ---------------------------
 * @author zhangyang
 * @date 2020/12/14 14:53
 */
public enum ErrorCodeEnum implements IErrorCode {


    OK(0, 200, "请求成功"),


    /**
     * 用户端错误
     */
    A0001(10001, UN_KNOW_RESPONSE_STATUS_CODE, "用户端错误"),
    A0100(10100, UN_KNOW_RESPONSE_STATUS_CODE, "用户注册错误"),
    A0101(10101, UN_KNOW_RESPONSE_STATUS_CODE, "用户未同意隐私协议"),
    A0102(10102, UN_KNOW_RESPONSE_STATUS_CODE, "注册国家或地区受限"),
    A0110(10110, UN_KNOW_RESPONSE_STATUS_CODE, "用户名校验失败"),
    A0111(10111, UN_KNOW_RESPONSE_STATUS_CODE, "用户名已存在"),
    A0112(10112, UN_KNOW_RESPONSE_STATUS_CODE, "用户名包含敏感词"),
    A0113(10113, UN_KNOW_RESPONSE_STATUS_CODE, "用户名包含特殊字符"),
    A0120(10120, UN_KNOW_RESPONSE_STATUS_CODE, "密码校验失败"),
    A0121(10121, UN_KNOW_RESPONSE_STATUS_CODE, "密码长度不够"),
    A0122(10122, UN_KNOW_RESPONSE_STATUS_CODE, "密码强度不够"),
    A0130(10130, UN_KNOW_RESPONSE_STATUS_CODE, "校验码输入错误"),
    A0131(10131, UN_KNOW_RESPONSE_STATUS_CODE, "短信校验码输入错误"),
    A0132(10132, UN_KNOW_RESPONSE_STATUS_CODE, "邮件校验码输入错误"),
    A0133(10133, UN_KNOW_RESPONSE_STATUS_CODE, "语音校验码输入错误"),
    A0140(10140, UN_KNOW_RESPONSE_STATUS_CODE, "用户证件异常"),
    A0141(10141, UN_KNOW_RESPONSE_STATUS_CODE, "用户证件类型未选择"),
    A0142(10142, UN_KNOW_RESPONSE_STATUS_CODE, "大陆身份证编号校验非法"),
    A0143(10143, UN_KNOW_RESPONSE_STATUS_CODE, "护照编号校验非法"),
    A0144(10144, UN_KNOW_RESPONSE_STATUS_CODE, "军官证编号校验非法"),
    A0150(10150, UN_KNOW_RESPONSE_STATUS_CODE, "用户基本信息校验失败"),
    A0151(10151, UN_KNOW_RESPONSE_STATUS_CODE, "手机格式校验失败"),
    A0152(10152, UN_KNOW_RESPONSE_STATUS_CODE, "地址格式校验失败"),
    A0153(10153, UN_KNOW_RESPONSE_STATUS_CODE, "邮箱格式校验失败"),

    A0200(10200, UN_KNOW_RESPONSE_STATUS_CODE, "用户登陆异常"),
    A0201(10201, UN_KNOW_RESPONSE_STATUS_CODE, "用户账户不存在"),
    A0202(10202, UN_KNOW_RESPONSE_STATUS_CODE, "用户账户被冻结"),
    A0203(10203, UN_KNOW_RESPONSE_STATUS_CODE, "用户账户已作废"),
    A0210(10210, UN_KNOW_RESPONSE_STATUS_CODE, "用户密码错误"),
    A0211(10211, UN_KNOW_RESPONSE_STATUS_CODE, "用户输入密码次数超限"),
    A0220(10220, UN_KNOW_RESPONSE_STATUS_CODE, "用户身份校验失败"),
    A0221(10221, UN_KNOW_RESPONSE_STATUS_CODE, "用户指纹识别失败"),
    A0222(10222, UN_KNOW_RESPONSE_STATUS_CODE, "用户面容识别失败"),
    A0223(10223, UN_KNOW_RESPONSE_STATUS_CODE, "用户未获得第三方登陆授权"),
    A0230(10230, UN_KNOW_RESPONSE_STATUS_CODE, "用户登陆已过期"),
    A0240(10240, UN_KNOW_RESPONSE_STATUS_CODE, "用户验证码错误"),
    A0241(10241, UN_KNOW_RESPONSE_STATUS_CODE, "用户验证码尝试次数超限"),


    A0300(10300, UN_KNOW_RESPONSE_STATUS_CODE, "访问权限异常"),
    A0301(10301, UN_KNOW_RESPONSE_STATUS_CODE, "访问未授权"),
    A0302(10302, UN_KNOW_RESPONSE_STATUS_CODE, "正在授权中"),
    A0303(10303, UN_KNOW_RESPONSE_STATUS_CODE, "用户授权申请被拒绝"),
    A0310(10310, UN_KNOW_RESPONSE_STATUS_CODE, "因访问对象隐私设置被拦截"),
    A0311(10311, UN_KNOW_RESPONSE_STATUS_CODE, "授权已过期"),
    A0312(10312, UN_KNOW_RESPONSE_STATUS_CODE, "无权限使用API"),
    A0320(10320, UN_KNOW_RESPONSE_STATUS_CODE, "用户访问被拦截"),
    A0321(10321, UN_KNOW_RESPONSE_STATUS_CODE, "黑名单用户"),
    A0322(10322, UN_KNOW_RESPONSE_STATUS_CODE, "账号被冻结"),
    A0323(10323, UN_KNOW_RESPONSE_STATUS_CODE, "非法IP地址"),
    A0324(10324, UN_KNOW_RESPONSE_STATUS_CODE, "网关访问受限"),
    A0325(10325, UN_KNOW_RESPONSE_STATUS_CODE, "地域黑名单"),
    A0330(10330, UN_KNOW_RESPONSE_STATUS_CODE, "服务已欠费"),
    A0340(10340, UN_KNOW_RESPONSE_STATUS_CODE, "用户签名异常"),
    A0341(10341, UN_KNOW_RESPONSE_STATUS_CODE, "RSA签名错误"),

    A0400(10400, UN_KNOW_RESPONSE_STATUS_CODE, "用户请求参数错误"),
    A0401(10401, UN_KNOW_RESPONSE_STATUS_CODE, "包含非法恶意跳转链接"),
    A0402(10402, UN_KNOW_RESPONSE_STATUS_CODE, "无效的用户输入"),
    A0410(10410, UN_KNOW_RESPONSE_STATUS_CODE, "请求必填参数为空"),
    A0411(10411, UN_KNOW_RESPONSE_STATUS_CODE, "用户订单号为空"),
    A0412(10412, UN_KNOW_RESPONSE_STATUS_CODE, "订购数量为空"),
    A0413(10413, UN_KNOW_RESPONSE_STATUS_CODE, "缺少时间戳参数"),
    A0414(10414, UN_KNOW_RESPONSE_STATUS_CODE, "非法的时间戳参数"),
    A0420(10420, UN_KNOW_RESPONSE_STATUS_CODE, "请求参数值超出允许的范围"),
    A0421(10421, UN_KNOW_RESPONSE_STATUS_CODE, "参数格式不匹配"),
    A0422(10422, UN_KNOW_RESPONSE_STATUS_CODE, "地址不在服务范围"),
    A0423(10423, UN_KNOW_RESPONSE_STATUS_CODE, "时间不在服务范围"),
    A0424(10424, UN_KNOW_RESPONSE_STATUS_CODE, "金额超出限制"),
    A0425(10425, UN_KNOW_RESPONSE_STATUS_CODE, "数量超出限制"),
    A0426(10426, UN_KNOW_RESPONSE_STATUS_CODE, "请求批量处理总个数超出限制"),
    A0427(10427, UN_KNOW_RESPONSE_STATUS_CODE, "请求JSON 解析失败"),
    A0430(10430, UN_KNOW_RESPONSE_STATUS_CODE, "用户输入内容非法"),
    A0431(10431, UN_KNOW_RESPONSE_STATUS_CODE, "包含违禁敏感词"),
    A0432(10432, UN_KNOW_RESPONSE_STATUS_CODE, "图片包含违禁信息"),
    A0433(10433, UN_KNOW_RESPONSE_STATUS_CODE, "文件侵犯版权"),
    A0440(10440, UN_KNOW_RESPONSE_STATUS_CODE, "用户操作异常"),
    A0441(10441, UN_KNOW_RESPONSE_STATUS_CODE, "用户支付超时"),
    A0442(10442, UN_KNOW_RESPONSE_STATUS_CODE, "确认订单超时"),
    A0443(10443, UN_KNOW_RESPONSE_STATUS_CODE, "订单已关闭"),

    A0500(10500, UN_KNOW_RESPONSE_STATUS_CODE, "用户请求服务异常"),
    A0501(10501, UN_KNOW_RESPONSE_STATUS_CODE, "请求次数超出限制"),
    A0502(10502, UN_KNOW_RESPONSE_STATUS_CODE, "请求并发数超出限制"),
    A0503(10503, UN_KNOW_RESPONSE_STATUS_CODE, "用户操作请等待"),
    A0504(10504, UN_KNOW_RESPONSE_STATUS_CODE, "WebSocket连接异常"),
    A0505(10505, UN_KNOW_RESPONSE_STATUS_CODE, "WebSocket连接断开"),
    A0506(10506, UN_KNOW_RESPONSE_STATUS_CODE, "用户重复请求"),

    A0600(10600, UN_KNOW_RESPONSE_STATUS_CODE, "用户资源异常"),
    A0601(10601, UN_KNOW_RESPONSE_STATUS_CODE, "账户余额不足"),
    A0602(10602, UN_KNOW_RESPONSE_STATUS_CODE, "用户磁盘空间不足"),
    A0603(10603, UN_KNOW_RESPONSE_STATUS_CODE, "用户内存空间不足"),
    A0604(10604, UN_KNOW_RESPONSE_STATUS_CODE, "用户OSS 容量不足"),
    A0605(10605, UN_KNOW_RESPONSE_STATUS_CODE, "用户配额已用光,蚂蚁森林浇水数或每天抽奖数"),

    A0700(10700, UN_KNOW_RESPONSE_STATUS_CODE, "用户上传文件异常"),
    A0701(10701, UN_KNOW_RESPONSE_STATUS_CODE, "用户上传文件类型不匹配"),
    A0702(10702, UN_KNOW_RESPONSE_STATUS_CODE, "用户上传文件太大"),
    A0703(10703, UN_KNOW_RESPONSE_STATUS_CODE, "用户上传图片太大"),
    A0704(10704, UN_KNOW_RESPONSE_STATUS_CODE, "用户上传视频太大"),
    A0705(10705, UN_KNOW_RESPONSE_STATUS_CODE, "用户上传压缩文件太大"),

    A0800(10800, UN_KNOW_RESPONSE_STATUS_CODE, "用户当前版本异常"),
    A0801(10801, UN_KNOW_RESPONSE_STATUS_CODE, "用户安装版本与系统不匹配"),
    A0802(10802, UN_KNOW_RESPONSE_STATUS_CODE, "用户安装版本过低"),
    A0803(10803, UN_KNOW_RESPONSE_STATUS_CODE, "用户安装版本过高"),
    A0804(10804, UN_KNOW_RESPONSE_STATUS_CODE, "用户安装版本已过期"),
    A0805(10805, UN_KNOW_RESPONSE_STATUS_CODE, "用户API 请求版本不匹配"),
    A0806(10806, UN_KNOW_RESPONSE_STATUS_CODE, "用户API 请求版本过高"),
    A0807(10807, UN_KNOW_RESPONSE_STATUS_CODE, "用户API 请求版本过低"),

    A0900(10900, UN_KNOW_RESPONSE_STATUS_CODE, "用户隐私未授权"),
    A0901(10901, UN_KNOW_RESPONSE_STATUS_CODE, "用户隐私未签署"),
    A0902(10902, UN_KNOW_RESPONSE_STATUS_CODE, "用户摄像头未授权"),
    A0903(10903, UN_KNOW_RESPONSE_STATUS_CODE, "用户相机未授权"),
    A0904(10904, UN_KNOW_RESPONSE_STATUS_CODE, "用户图片库未授权"),
    A0905(10905, UN_KNOW_RESPONSE_STATUS_CODE, "用户文件未授权"),
    A0906(10906, UN_KNOW_RESPONSE_STATUS_CODE, "用户位置信息未授权"),
    A0907(10907, UN_KNOW_RESPONSE_STATUS_CODE, "用户通讯录未授权"),

    A1000(11000, UN_KNOW_RESPONSE_STATUS_CODE, "用户设备异常"),
    A1001(11001, UN_KNOW_RESPONSE_STATUS_CODE, "用户相机异常"),
    A1002(11002, UN_KNOW_RESPONSE_STATUS_CODE, "用户麦克风异常"),
    A1003(11003, UN_KNOW_RESPONSE_STATUS_CODE, "用户听筒异常"),
    A1004(11004, UN_KNOW_RESPONSE_STATUS_CODE, "用户扬声器异常"),
    A1005(11005, UN_KNOW_RESPONSE_STATUS_CODE, "用户GPS 定位异常"),
    /**
     * 以下针对http原有状态码的封装
     */
    A2100(12100, 100, "继续。客户端应继续其请求"),
    A2101(12101, 101, "切换协议。服务器根据客户端的请求切换协议。只能切换到更高级的协议，例如，切换到HTTP的新版本协议"),

    A2201(12201, 201, "已创建。成功请求并创建了新的资源"),
    A2202(12202, 202, "已接受。已经接受请求，但未处理完成"),
    A2203(12203, 203, "非授权信息。请求成功。"),
    A2204(12204, 204, "无内容。服务器成功处理，但未返回内容。"),
    A2205(12205, 205, "重置内容。服务器处理成功，用户终端（例如：浏览器）应重置文档视图。"),
    A2206(12206, 206, "部分内容。服务器成功处理了部分GET请求"),

    A2300(12300, 300, "多种选择。请求的资源可包括多个位置，相应可返回一个资源特征与地址的列表用于用户终端选择"),
    A2301(12301, 301, "永久移动。"),
    A2302(12302, 302, "临时移动。"),
    A2303(12303, 303, "查看其它地址。"),
    A2304(12304, 304, "未修改。所请求的资源未修改，服务器返回此状态码时，不会返回任何资源。"),
    A2305(12305, 305, "使用代理。所请求的资源必须通过代理访问"),
    A2306(12306, 306, "已经被废弃的HTTP状态码"),
    A2307(12307, 307, "临时重定向。与302类似。使用GET请求重定向"),


    A2400(12400, 400, "客户端请求的语法错误，服务器无法理解"),
    A2401(12401, 401, "请求要求用户的身份认证"),
    A2402(12402, 402, "保留，将来使用"),
    A2403(12403, 403, "服务器理解请求客户端的请求，但是拒绝执行此请求"),
    A2404(12404, 404, "服务器无法根据客户端的请求找到资源"),
    A2405(12405, 405, "客户端请求中的方法被禁止"),
    A2406(12406, 406, "服务器无法根据客户端请求的内容特性完成请求"),
    A2407(12407, 407, "请求者应当使用代理进行授权"),
    A2408(12408, 408, "服务器等待客户端发送的请求时间过长，超时"),
    A2409(12409, 409, "服务器处理请求时发生了冲突"),
    A2410(12410, 410, "资源以前有现在被永久删除了"),
    A2411(12411, 411, "服务器无法处理客户端发送的不带Content-Length的请求信息"),
    A2412(12412, 412, "客户端请求信息的先决条件错误"),
    A2413(12413, 413, "由于请求的实体过大，服务器无法处理，因此拒绝请求。为防止客户端的连续请求，服务器可能会关闭连接。如果只是服务器暂时无法处理，则会包含一个Retry-After的响应信息"),
    A2414(12414, 414, "请求的URI过长（URI通常为网址），服务器无法处理"),
    A2415(12415, 415, "服务器无法处理请求附带的媒体格式"),
    A2416(12416, 416, "客户端请求的范围无效"),
    A2417(12417, 417, "服务器无法满足Expect的请求头信息"),





    /**
     * 系统执行出错
     */
    FAIL(20001, 500, "系统执行出错"),

    B0100(20100, UN_KNOW_RESPONSE_STATUS_CODE, "系统执行超时"),
    B0101(20101, UN_KNOW_RESPONSE_STATUS_CODE, "系统订单处理超时"),

    B0200(20200, UN_KNOW_RESPONSE_STATUS_CODE, "系统容灾功能被触发"),
    B0210(20210, UN_KNOW_RESPONSE_STATUS_CODE, "系统限流"),
    B0220(20220, UN_KNOW_RESPONSE_STATUS_CODE, "系统功能降级"),

    B0300(20300, UN_KNOW_RESPONSE_STATUS_CODE, "系统资源异常"),
    B0310(20310, UN_KNOW_RESPONSE_STATUS_CODE, "系统资源耗尽"),
    B0311(20311, UN_KNOW_RESPONSE_STATUS_CODE, "系统磁盘空间耗尽"),
    B0312(20312, UN_KNOW_RESPONSE_STATUS_CODE, "系统内存耗尽"),
    B0313(20313, UN_KNOW_RESPONSE_STATUS_CODE, "文件句柄耗尽"),
    B0314(20314, UN_KNOW_RESPONSE_STATUS_CODE, "系统连接池耗尽"),
    B0315(20315, UN_KNOW_RESPONSE_STATUS_CODE, "系统线程池耗尽"),
    B0320(20320, UN_KNOW_RESPONSE_STATUS_CODE, "系统资源访问异常"),
    B0321(20321, UN_KNOW_RESPONSE_STATUS_CODE, "系统读取磁盘文件失败"),

    /**
     * 以下针对http原有状态码的封装
     */
    B2501(22501, 501, "系统不支持请求的功能，无法完成请求"),
    B2502(22502, 502, "作为网关或者代理工作的服务器尝试执行请求时，从远程服务器接收到了一个无效的响应"),
    B2503(22503, 503, "由于超载或系统维护，服务器暂时的无法处理客户端的请求。延时的长度可包含在服务器的Retry-After头信息中"),
    B2504(22504, 504, "充当网关或代理的服务器，未及时从远端服务器获取请求"),
    B2505(22505, 505, "系统不支持请求的HTTP协议的版本，无法完成处理"),

    /**
     * 调用第三方服务出错
     */
    C0001(30001, UN_KNOW_RESPONSE_STATUS_CODE, "调用第三方服务出错 一级宏观错误码"),
    C0100(30100, UN_KNOW_RESPONSE_STATUS_CODE, "中间件服务出错 二级宏观错误码"),
    C0110(30110, UN_KNOW_RESPONSE_STATUS_CODE, "RPC 服务出错"),
    C0111(30111, UN_KNOW_RESPONSE_STATUS_CODE, "RPC 服务未找到"),
    C0112(30112, UN_KNOW_RESPONSE_STATUS_CODE, "RPC 服务未注册"),
    C0113(30113, UN_KNOW_RESPONSE_STATUS_CODE, "接口不存在"),
    C0120(30120, UN_KNOW_RESPONSE_STATUS_CODE, "消息服务出错"),
    C0121(30121, UN_KNOW_RESPONSE_STATUS_CODE, "消息投递出错"),
    C0122(30122, UN_KNOW_RESPONSE_STATUS_CODE, "消息消费出错"),
    C0123(30123, UN_KNOW_RESPONSE_STATUS_CODE, "消息订阅出错"),
    C0124(30124, UN_KNOW_RESPONSE_STATUS_CODE, "消息分组未查到"),
    C0130(30130, UN_KNOW_RESPONSE_STATUS_CODE, "缓存服务出错"),
    C0131(30131, UN_KNOW_RESPONSE_STATUS_CODE, "key 长度超过限制"),
    C0132(30132, UN_KNOW_RESPONSE_STATUS_CODE, "value 长度超过限制"),
    C0133(30133, UN_KNOW_RESPONSE_STATUS_CODE, "存储容量已满"),
    C0134(30134, UN_KNOW_RESPONSE_STATUS_CODE, "不支持的数据格式"),
    C0140(30140, UN_KNOW_RESPONSE_STATUS_CODE, "配置服务出错"),
    C0150(30150, UN_KNOW_RESPONSE_STATUS_CODE, "网络资源服务出错"),
    C0151(30151, UN_KNOW_RESPONSE_STATUS_CODE, "VPN 服务出错"),
    C0152(30152, UN_KNOW_RESPONSE_STATUS_CODE, "CDN 服务出错"),
    C0153(30153, UN_KNOW_RESPONSE_STATUS_CODE, "域名解析服务出错"),
    C0154(30154, UN_KNOW_RESPONSE_STATUS_CODE, "网关服务出错"),
    C0200(30200, UN_KNOW_RESPONSE_STATUS_CODE, "第三方系统执行超时 二级宏观错误码"),
    C0210(30210, UN_KNOW_RESPONSE_STATUS_CODE, "RPC 执行超时"),
    C0220(30220, UN_KNOW_RESPONSE_STATUS_CODE, "消息投递超时"),
    C0230(30230, UN_KNOW_RESPONSE_STATUS_CODE, "缓存服务超时"),
    C0240(30240, UN_KNOW_RESPONSE_STATUS_CODE, "配置服务超时"),
    C0250(30250, UN_KNOW_RESPONSE_STATUS_CODE, "数据库服务超时"),
    C0300(30300, UN_KNOW_RESPONSE_STATUS_CODE, "数据库服务出错 二级宏观错误码"),
    C0311(30311, UN_KNOW_RESPONSE_STATUS_CODE, "表不存在"),
    C0312(30312, UN_KNOW_RESPONSE_STATUS_CODE, "列不存在"),
    C0321(30321, UN_KNOW_RESPONSE_STATUS_CODE, "多表关联中存在多个相同名称的列"),
    C0331(30331, UN_KNOW_RESPONSE_STATUS_CODE, "数据库死锁"),
    C0341(30341, UN_KNOW_RESPONSE_STATUS_CODE, "主键冲突"),
    C0400(30400, UN_KNOW_RESPONSE_STATUS_CODE, "第三方容灾系统被触发 二级宏观错误码"),
    C0401(30401, UN_KNOW_RESPONSE_STATUS_CODE, "第三方系统限流"),
    C0402(30402, UN_KNOW_RESPONSE_STATUS_CODE, "第三方功能降级"),
    C0500(30500, UN_KNOW_RESPONSE_STATUS_CODE, "通知服务出错 二级宏观错误码"),
    C0501(30501, UN_KNOW_RESPONSE_STATUS_CODE, "短信提醒服务失败"),
    C0502(30502, UN_KNOW_RESPONSE_STATUS_CODE, "语音提醒服务失败"),
    C0503(30503, UN_KNOW_RESPONSE_STATUS_CODE, "邮件提醒服务失败");

    private final int intCode;
    private final int responseStatusCode;
    private final String msg;


    private static final HashBasedTable<Integer,Integer,ErrorCodeEnum> errorCodeTable = HashBasedTable.create(175,3);
    static {
        for(ErrorCodeEnum codeEnum:ErrorCodeEnum.values()){
            errorCodeTable.put(codeEnum.getIntCode(),codeEnum.getResponseStatusCode(),codeEnum);
        }
    }

    ErrorCodeEnum(int intCode, int responseStatusCode,String msg) {
        this.msg = msg;
        this.intCode = intCode;
        this.responseStatusCode = responseStatusCode;
    }

    @Override
    public String getCode() {
        if(OK==this){
            return RESULT_OK_CODE;
        }
        if(FAIL== this){
            return RESULT_ERROR_CODE;
        }
        return this.name();
    }


    @Override
    public String getMsg() {
        return msg;
    }

    @Override
    public int getIntCode() {
        return intCode;
    }

    @Override
    public int getResponseStatusCode() {
        return responseStatusCode;
    }

    /**
     * 根据整形状态码返回状态码
     *
     * @param intCode
     * @return
     */
    public static ErrorCodeEnum getCodeByIntCode(int intCode) {
        if(!errorCodeTable.containsRow(intCode)){
            return null;
        }
        Map<Integer,ErrorCodeEnum> rowMap = errorCodeTable.row(intCode);
        return rowMap.values().iterator().next();
    }

    /**
     * 根据http响应状态码返回状态码
     *
     * @param responseStatusCode
     * @return
     */
    public static ErrorCodeEnum getCodeByResponseStatusCode(int responseStatusCode) {
        if(!errorCodeTable.containsColumn(responseStatusCode)){
            return null;
        }
        Map<Integer, ErrorCodeEnum> columnMap = errorCodeTable.column(responseStatusCode);
        return columnMap.values().iterator().next();
    }

    public static ErrorCodeEnum getCodeByNum(int num){
        ErrorCodeEnum code = getCodeByResponseStatusCode(num);
        if(code ==null){
            code = getCodeByIntCode(num);
        }
        return code;
    }


}
